package android_testsuite.mytest.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
/**
 * 数据库访问工厂类
 * @author RenHui
 */
public class DatabaseAccessFactory  {
    private static DatabaseAccessFactory mInstance;

    private DatabaseAdapter mSqliteAdapter;
    private SQLiteDatabase mDatabase;

    // 构造函数
    private DatabaseAccessFactory(Context context) {
        super();
        this.mSqliteAdapter = new DatabaseAdapter(context.getApplicationContext());
        this.mDatabase = this.mSqliteAdapter.getDatabase();
    }

    /**
     * 获取数据库访问工厂对象（单例）*
     * @param context
     * @return
     */
    public static synchronized DatabaseAccessFactory getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new DatabaseAccessFactory(context);
        }

        return mInstance;
    }
}
